/*
 * network.cpp
 *
 *  Created on: 11.04.2012
 *      Author: delgado
 */
#include "network.h"

#include <cstdlib>
using std::rand;
using std::srand;
#include <ctime>
using std::time;
#include <algorithm>
using std::find;

using std::endl;

namespace neurignacio{

Topology::Topology(const number_t n, const real c) : AdjacencyGraph(), n(n), c(c)
{
	// Reset the seed
	srand(time(NULL));
	// Create random graph of neurons
	for (Neuron i=0; i<n; ++i)
		for (Neuron j=0; j<n; ++j)
			if ((i!=j) && (static_cast<real>(rand()) / RAND_MAX < c))
				(*this)[i].push_back(j);
}

ostream& operator<<(ostream& out, Topology& topology)
{
	for (Neuron i=0; i<topology.n; ++i)
	{
	for (Neuron j=0; j<topology.n; ++j)
		if (find(topology[i].begin(), topology[i].end(), j)!=topology[i].end())
			out << "1 ";
		else
			out << "0 ";
	out << endl;
	}
	return out;

}

} // end namespace neurignacio


